<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page import="com.webapp.model.Circle, java.util.List" %>
<% 
	List myCircles =  (List)session.getAttribute("Circles");
	System.out.print(myCircles);
	if(myCircles == null)
		response.sendRedirect("Error.jsp");
%>
<!-- include moo talk header file -->
<%@ include file="MooTalkHeader.jsp" %>	
		<div id="site_content_text">
			<% 
				String x = request.getParameter("circle"); 
				if(x != null) {
					
					if(x.equals("created")) {
						%>
							<p style="color:red;">
								Fence Created!
							</p>
						<%
					}
					
					if(x.equals("added")) {
						%>
							<p style="color:red;">
								Your fence was built! Please have a great day!
							</p>
						<%
					}
					
					if(x.equals("deleted")) {
						%>
							<p style="color:red;">
								Your fence was removed!
							</p>
						<%
					}
					
					if(x.equals("disable")) {
						%>
							<p style="color:red;">
								You do not have this function!
							</p>
						<%
					}
					
					if(x.equals("error")) {
						%>
							<p style="color:red;">
								There was an error creating the circle!
							</p>
						<%
					}
					
					if(x.equals("no circles")) {
						%>
							<p style="color:red;">
								Sorry you have no circles!
							</p>
						<%
					}
					if(x.equals("postadded")) {
						%>
							<p style="color:red;">
								Your post was added!
							</p>
						<%
					}
					if(x.equals("errorpost")) {
						%>
							<p style="color:red;">
								Sorry there was an error posting!
							</p>
						<%
					}
				} 
			%>
			
			<% if (user.getType().toLowerCase().equals("user")) { %>
				<h2>Your Fences</h2>
				<% if (myCircles.size() == 0) { %>
					<p>You need to go make some friends and round them up!</p>
				<% } else {
					for(int i = 0; i < myCircles.size(); i++) { 
						Circle theCircle = (Circle)myCircles.get(i);
						if(i%2 == 0) { %>
						<div class="even">
						<%
						} else { %>
						<div class="odd">
						<% }%>
							<br/>
							<form id="viewFence" name="viewFence" action="ViewCircle.do" method="post">
								<!--  fence id value -->
								<label><strong>Fence Name: </strong><%=theCircle.getCircleName()%></label><br/>
								<label><strong>Fence Type: </strong> <%=theCircle.getCircleType()%></label><br/>
								<input type="hidden" name="fenceIDTxt" value="<%=theCircle.getCircleId()%>"/>
								<input class="btn" type="submit" value="View Friends or Fix your Fence!"/>
							</form>
							<br/>
						 </div>
				<% }
				} %>
				
				<br/>
			<hr/>
			<br/>
				<form id="createFence" name="createFence" action="CreateCircle.do" method="post">
					<h2>Create a New Fence</h2>
					<label><strong>Fence Name:</strong></label><br/>
					<input type="text" name="fenceNameTxt"/><br/>
					<label><strong>Fence Type:</strong></label><br/>
					<input type="text" name="fenceTypeTxt"/>
					<input class="btn"type="submit" value="Create Fence" />
				</form>
				<br/>
			<% } else { %>
				<h2>You can not create a circle because you are a <%=user.getType()%>!</h2>
			<% } %>
			<br/>
			<hr/>
			<br/>
		</div>
		
<!--  include moo talk footer file -->
<%@ include file="MooTalkFooter.jsp" %>
